<template>
    <el-container class="course-container-page">
        <el-header height="auto">
            <headers/>
        </el-header>
        <el-main>
            <div class="flex flex-col h-full">
                <div>
                    <div class="router flex items-center">
                        <el-button @click="toHelp" type="text" class="item">选课</el-button>
                        <i class="mx-2 el-icon-arrow-right"></i>
                        <el-button type="text" class="item active">{{ theme }}</el-button>
                    </div>
                    <div class="w-full">
                        <div class="steps flex justify-center">
                            <div class="step">
                                <div class="step-num active">1</div>
                                <div class="step-content">选择一个角色或方向</div>
                            </div>
                            <div class="line active"></div>
                            <div class="step">
                                <div class="step-num active">2</div>
                                <div class="step-content">选择想学的主题</div>
                            </div>
                            <div :class="`line ${routeName === 'Course.Selection.Detail' ? '' : 'active'}`"></div>
                            <div class="step">
                                <div :class="`step-num ${routeName === 'Course.Selection.Detail'
                                    ? '' : 'active'}`">3</div>
                                <div class="step-content">获得你的团队学习提案</div>
                            </div>
                        </div>
                        <div class="banner text-center">
                            <img src="@/assets/images/course/detail-banner1.png" alt="">
                            <p class="title relative">{{ theme }}</p>
                            <p class="desc relative">
                                {{ description }}
                            </p>
                        </div>
                    </div>
                    <div class="page-view">
                        <router-view></router-view>
                    </div>
                </div>
                <Footers class="mt-auto"/>
            </div>
        </el-main>
    </el-container>
</template>

<script>
import {
    Container,
    Header,
    Main,
} from 'element-ui';
import Headers from '@/components/layout/Header';
import Footers from '@/components/layout/Footer';

export default {
    components: {
        ElContainer: Container,
        ElMain: Main,
        ElHeader: Header,
        Headers,
        Footers,
    },
    data() {
        return {
            content: '',

            theme: '',
            description: '',

            routeName: 'Course.Selection.Detail',
        };
    },
    watch: {
        $route(val) {
            this.routeName = val.name;
        },
    },
    methods: {
        toHelp() {
            this.$router.push({name: 'Course.Selection'});
        },
        fetchData(id) {
            API.get(`../elective/${id}`).then(res => {
                this.theme = res.theme;
                this.description = res.description;
            });
        },
    },
    mounted() {
        const id = this.$route.query.id;

        if (id) this.fetchData(id);

        this.routeName = this.$route.name;
    },
};
</script>

<style lang="scss">
.course-container-page {
    width: 100vw;
    height: 100vh;

    .el-main {
        padding: 0;
    }

    .el-header {
        box-shadow: 1px 1px 10px 1px rgba($color: #000000, $alpha: .1);

        @media (max-width: 960px) {
            box-shadow: 0 2px 4px 0 rgba($color: #000000, $alpha: .1);
            padding: 0;
        }
    }

    .router {
        max-width: 1024px;
        height: 60px;
        margin: 0 auto;

        @media (max-width: 960px) {
            font-size: 12px;
            height: initial;
            margin: 16px 0 24px 20px;
        }

        .item {
            color: rgb(180, 180, 180);

            @media (max-width: 960px) {
                padding: 0;

                &:last-child {
                    max-width: 150px;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                }
            }
        }

        .item:hover {
            color: #409eff;
        }

        .item.active {
            color: rgb(37, 37, 37);
        }
    }

    .page-view {
        max-width: 1024px;
        margin: 0 auto;
        padding-bottom: 40px;

        @media (max-width: 960px) {
            padding: 28px 20px 20px;
        }
    }

    .steps {
        margin-top: 60px;
        padding-bottom: 108px;

        @media (max-width: 960px) {
            margin-top: 38px;
        }

        .step {
            position: relative;

            .step-num {
                width: 60px;
                height: 60px;
                line-height: 60px;
                border-radius: 50%;
                border: 1px solid rgb(215, 215, 215);
                text-align: center;
                font-size: 30px;
                font-weight: bold;
                color: rgb(215, 215, 215);

                @media (max-width: 960px) {
                    width: 40px;
                    height: 40px;
                    line-height: 40px;
                    font-size: 20px;
                }
            }

            .step-num.active {
                border-color: #2d70ae;
                color: #2d70ae;
            }

            .step-content {
                position: absolute;
                top: 85px;
                left: 50%;
                transform: translateX(-50%);
                width: 260px;
                text-align: center;
                font-size: 20px;
                font-weight: bold;

                @media (max-width: 960px) {
                    font-size: 12px;
                    line-height: 17px;
                    width: 72px;
                    top: 56px;
                }
            }
        }

        .line {
            width: 225px;
            margin: 29px 16px 0 16px;
            border-top: 2px dashed rgb(215, 215, 215);

            @media (max-width: 960px) {
                width: 75px;
                margin: 20px 0 0;
                border-top-width: 1px;
            }
        }

        .line.active {
            border-top-color: #2d70ae;
        }
    }

    .banner {
        position: relative;
        width: 100%;
        height: 200px;
        color: white;

        @media (max-width: 960px) {
            height: initial;
            padding: 37px 20px 40px;
        }

        img {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
        }

        .title, .desc {
            max-width: 1024px;
            margin: 0 auto;
        }

        .title {
            font-size: 30px;
            margin-bottom: 20px;
            padding-top: 48px;
            font-weight: bold;

            @media (max-width: 960px) {
                font-size: 20px;
                line-height: 28px;
                margin-bottom: 20px;
                padding-top: 0;
            }
        }

        .desc {
            @media (max-width: 960px) {
                font-size: 14px;
                line-height: 20px;
                text-align: left;
            }
        }
    }
}
</style>
